
Partial Class Login
    Inherits EviPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn

        Me.Session("InitialPage") = FormsAuthentication.GetRedirectUrl(Login1.UserName, False)
    End Sub

    Protected Sub Login1_LoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs) Handles Login1.LoggingIn
        'Obtenemos el Cliente
        Dim tadclientesusuarios As New EVITableAdapters.ClientesUsuariosTableAdapter
        Dim tableclienteusuarios As EVI.ClientesUsuariosDataTable

        tableclienteusuarios = tadclientesusuarios.GetDataByUserId(Me.Login1.UserName)
        If tableclienteusuarios.Rows.Count > 0 Then
            Dim tadcliente As New EVITableAdapters.ClientesTableAdapter
            Dim tableclientes As EVI.ClientesDataTable
            tableclientes = tadcliente.GetDataByIdCliente(tableclienteusuarios.Rows(0)("idCliente"))
            If tableclientes.Rows.Count > 0 Then
                If DirectCast(tableclientes.Rows(0)("Bloqueado"), Boolean) Then
                    Dim men As String = String.Empty
                    Select Case Left(Session("selectedLanguage"), 2).ToUpper
                        Case "ES"
                            men = "alert('No se permite el acceso, el cliente est\u00e1 bloqueado.');"
                        Case "CA"
                            men = "alert('No es permet l\u0027acc\u00e9s, el client est\u00e0 bloquejat.');"
                    End Select

                    Me.ClientScript.RegisterStartupScript(Me.GetType(), "erroUsuario", men, True)
                    e.Cancel = True
                End If
            End If
        End If
    End Sub
End Class
